package org.basic.algorithm;

import java.util.Scanner;

/**
 * HuaWei
 *
 * @author 李坤
 * @date 2022/3/13 19:39
 */
public class HuaWei {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        if (n == 0) {
            System.out.println(0);
        } else {
            int ans = 0, x;
            for (int i = 0; i <= n; i++) {
                String nextLine = "";
                int[] ints = new int[n];
                if (scanner.hasNext() && (nextLine = scanner.nextLine()).length() > 0) {
                    String[] split = nextLine.split(",");
                    for (int j = 0; j < n; j++) {
                        ints[j] = Integer.parseInt(split[j]);
                    }
                    ans += calculateMaxValue(ints);
                }
            }
            System.out.println(ans);
        }
    }

    private static int calculateMaxValue(int[] array) {
        int total = 0;

        for (int j : array) {
            total += j;
        }

        if (total == 0) {
            return 0;
        } else if (total == 1) {
            return 1 << array.length - 1;
        } else {
            int jinWei = 0;
            int maxValue = 0;
            int graterIndex = 0;
            int[] graterIndexArray = new int[total];

            for (int i = 0; i < array.length; i++) {
                if (array[i] == 1) {
                    if (graterIndex == 0) {
                        jinWei = i;
                    }
                    graterIndexArray[graterIndex++] = (i - jinWei);
                }
            }

            return dealArray(graterIndexArray, array.length);
        }
    }

    private static int dealArray(int[] graterIndexArray, int length) {
        int result = 0;
        for (int i = 0; i < graterIndexArray.length; i++) {
            int current = 0;
            int currentIndex = graterIndexArray[i];
            for (int j = 0; j < graterIndexArray.length; j++) {
                if (j < i) {
                    graterIndexArray[j] = graterIndexArray[j] - currentIndex + length;
                } else {
                    graterIndexArray[j] = graterIndexArray[j] - currentIndex;
                }
            }
            current = getIntValue(graterIndexArray, length - 1);
            result = Math.max(result, current);
        }
        return result;
    }

    private static int getIntValue(int[] graterIndexArray, int length) {
        int result = 0;
        for (int j : graterIndexArray) {
            result += 1 << (length - j);
        }
        return result;
    }
}
